from langchain_community.llms import Tongyi
import os

class Tongyi_llm:
    _llm_instance = None

    def create_llm(cls, key):
        os.environ["DASHSCOPE_API_KEY"] = key
        if not cls._llm_instance:
            cls._llm_instance = Tongyi()
        return cls._llm_instance

    def invoke(cls, user_input):
        return cls._llm_instance.invoke(user_input)
